class Web::HomesController < ApplicationController
  skip_before_action :verify_authenticity_token, only: [:build_content_us]
  # GET /admin/admin_users
  def index
    # 公司
    @company = Company.find_by(used: true)
    # 导航栏
    @naviga_bars = NavigaBar.where(company_id: @company.id).order(:order_number, :created_at)
    # 展示案例
    @technical_cores = TechnicalCore.where(company_id: @company.id).order(:order_number, :created_at)
    # 技术核心标题
    @naviga_bar_core_title = NavigaBar.find_by(key: 'priorities').name
    # 案例组标题
    @company_case_tile = NavigaBar.find_by(key: 'portfolio').name
    # 案例组列表
    @company_cases = CompanyCase.where(company_id: @company.id).order(:order_number, :created_at)
    # 关于我们
    @about_us_tile = NavigaBar.find_by(key: 'about').name
    # 轮播图
    @carousels = Carousel.where(company_id: @company.id).order(:order_number, :created_at)
    # 团队名称标题
    @team_title = NavigaBar.find_by(key: 'team').name
    # 团队
    @teams = Team.where(company_id: @company.id).order(:order_number, :created_at)
    # 联系我们标题
    @content_us_title = NavigaBar.find_by(key: 'contact').name
    # 联系客服
    @user_custom = UserCustom.order(:updated_at).first
  end

  # 创建联系我们
  def build_content_us
    @company = Company.find_by(used: true)
    guest_book = GuestBook.new(content: params[:content], name: params[:name], phone: params[:phone], admin_user_id: @company.admin_user_id)
    @status = guest_book.save
  end

  # private
  #   # Use callbacks to share common setup or constraints between actions.
  #   def set_admin_user
  #     @admin_user = AdminUser.find(params[:id])
  #   end

  #   # Only allow a trusted parameter "white list" through.
  #   def admin_user_params
  #     params.require(:admin_user).permit(:account_number, :name, :phone, :password)
  #   end
end
